package com.atguigu.java4;

/**
 * @author yihu
 * @create 2021-06-17 15:15
 * @email:1057202547@qq.com
 * @dec: 静态代理 特点：代理类和被代理类在编译期间，就确定下来了。
 */
public class StaticProxyTest {

    public static void main(String[] args) {
        ProxyClothFactory proxyClothFactory = new ProxyClothFactory(new NikeClothFactory());
        proxyClothFactory.produceCloth();
    }

}

//代理类
class  ProxyClothFactory implements  ClothFactory {
    //被代理类对象进行实例化
    private final ClothFactory factory;

    public ProxyClothFactory(ClothFactory clothFactory){
        this.factory = clothFactory;
    }

    @Override
    public void produceCloth() {
        System.out.println("代理工厂做一些准备工作");
        factory.produceCloth();
        System.out.println("代理工厂做一些后续的收尾工作");
    }
}

//被代理类
class NikeClothFactory implements ClothFactory{
    @Override
    public void produceCloth() {
        System.out.println("Nike工厂生产一批运动服");
    }
}
